@extends('admin.common.web')

@section('title','权限修改')

@section('content')
<!-- Page Content -->
    <!-- Page Breadcrumb -->
    <div class="page-breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <a href="{{ route('admin.index.index') }}">系统</a>
            </li>
            <li>
                <a href="{{ route('admin.permission.index') }}">权限管理</a>
            </li>
            <li class="active">修改权限</li>
        </ul>
    </div>
    <!-- /Page Breadcrumb -->
    <!-- Page Body -->
    <div class="page-body">

        <div class="row">
            <div class="col-lg-12 col-sm-12 col-xs-12">
                <div class="widget">
                    <div class="widget-header bordered-bottom bordered-blue">
                        <span class="widget-caption">修改权限</span>
                    </div>

                    <div class="widget-body">
                        <div id="horizontal-form">
                            @include('admin.common.msg')
                            @include('admin.common.error')
                            <form class="form-horizontal" action="{{ route('admin.permission.update',['id'=>$permission['id']]) }}" method="post">
                                @csrf
                                <div class="form-group">
                                    <label for="group_id" class="col-sm-2 control-label no-padding-right">上级权限</label>
                                    <div class="col-sm-6">
                                        <select name="pid" style="width: 100%;">
                                            <option value="0">顶级权限</option>
                                            @foreach($permissionList as $k => $v)
                                                <option @if($v['id'] == $permission['pid']) selected @endif value="{{ $v['id'] }}"><?php echo str_repeat('----',$v['level'])?>{{ $v['permission_name'] }}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="username" class="col-sm-2 control-label no-padding-right">权限名称</label>
                                    <div class="col-sm-6">
                                        <input class="form-control" value="{{ $permission['permission_name'] }}" name="permission_name" required type="text">
                                    </div>


                                    @if($errors->has('permission_name'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('permission_name') }}</p>
                                    @else
                                        <p class="help-block col-sm-4 red">* 必填</p>
                                    @endif

                                    <input name="id" value="{{ $permission['id'] }}" type="hidden"/>
                                </div> 
                                
                                <div class="form-group">
                                    <label for="username" class="col-sm-2 control-label no-padding-right">权限路由</label>
                                    <div class="col-sm-6">
                                        <input class="form-control" value="{{ $permission['route_url'] }}" name="route_url" type="text">
                                    </div>


                                    @if($errors->has('route_url'))
                                        <p class="help-block col-sm-4 blue">{{ $errors->first('route_url') }}</p>
                                    @else
                                        <p class="help-block col-sm-4 red">* 必填</p>
                                    @endif

                                    <input name="id" value="{{ $permission['id'] }}" type="hidden"/>
                                </div>

                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <button type="submit" class="btn btn-info">保存信息</button>
                                        <a href="JavaScript:window.history.go(-1);" class="btn btn-default">返回</a>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <!-- /Page Body -->
@endsection